IniReadInt Function

public function IniReadInt(key, iniDB, section, subSection, default)

read an integer corresponding to Key

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: key
type(IniList), intent(in) :: iniDB
character(len=*), intent(in), optional :: section
character(len=*), intent(in), optional :: subSection
integer(kind=long), intent(in), optional :: default

Return Value integer(kind=long)


Variables

Type Visibility Attributes Name Initial
character(len=stringLen), public :: s

Source Code

FUNCTION IniReadInt &
!
(key, iniDB, section, subSection, default)

IMPLICIT NONE

! subroutine arguments 
! Scalar arguments with intent(in):
CHARACTER (LEN = *),             INTENT(IN) :: key
TYPE (IniList)     ,             INTENT(IN) :: iniDB
CHARACTER (LEN = *),   OPTIONAL, INTENT(IN) :: section
CHARACTER (LEN = *),   OPTIONAL, INTENT(IN) :: subSection
INTEGER (KIND = long), OPTIONAL, INTENT(in) :: default
! Scalar arguments with intent(out):
INTEGER (KIND = long) :: IniReadInt
! Local Scalars:
CHARACTER(LEN = stringLen) :: s

!------------end of declaration------------------------------------------------

IF ( PRESENT (section) .AND. PRESENT (subSection) ) THEN
	s = IniReadString(key, iniDB, section = section, subSection = subSection)
ELSE IF ( PRESENT (section) .AND. .NOT.PRESENT (subSection)) THEN
	s = IniReadString(key, iniDB, section = section)
ELSE
	s = IniReadString(key, iniDB)
ENDIF
  
IF (s == '') THEN
	IF ( PRESENT (default) )THEN
		IniReadInt = default
	ELSE
		CALL Catch ('error', 'read ini file',      &
				    'key not found: ' , code = iniIOError, &
					 argument = key )
	ENDIF
ELSE
	READ (s,*, IOSTAT = ios) IniReadInt
	IF (ios > 0) THEN
		CALL Catch ('error', 'read ini file',   &
				  'error reading integer for key: ' ,  &
				  code = iniIOError, argument = key )
	ENDIF
END IF

RETURN

END FUNCTION IniReadInt